package leetcode.code0518;

import leetcode.IDebug;
import leetcode.helper.H;

public class Solution implements IDebug {

	public int change(int amount, int[] coins) {
		int[] dp = new int[amount + 1];
		dp[0] = 1;
		for (int j = 0; j < coins.length; j++) {
			int c = coins[j];
			for (int i = 1; i <= amount; i++) {
				if (i - c >= 0) {
					dp[i] += dp[i - c];
				}
			}
		}
		return dp[amount];
	}

	public int change2(int amount, int[] coins) {
		int[] dp = new int[amount + 1];
		for (int i = 1; i <= amount; i++) {
			int ans = 0;
			for (int j = 0; j < coins.length; j++) {
				int c = coins[j];
				if (i - c > 0) {
					ans = dp[i - c];
				} else if (i == c) {
					ans += 1;
				}
			}
			dp[i] = ans;
		}
		return dp[amount];
	}

	@Override
	public void debug4() {
		H.compare(4, this.change(5, H.str2array3("[1,2,5]")));

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
